package 线程的学习.udp和tcp的学习;

import java.io.DataInputStream;
import java.io.IOException;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;

public class Test1_Server {


    public static void main(String[] args) {
        Socket socket=null;
        ServerSocket serverSocket=null;
        DataInputStream dis=null;
        try {
            serverSocket=new ServerSocket(8888);
            socket=serverSocket.accept();
            dis=new DataInputStream(socket.getInputStream());
            System.out.println(dis.readUTF());

        } catch (IOException e) {
            System.out.println("服务器创建失败");
            e.printStackTrace();
        }finally {

                try {
                    if(dis!=null) {
                    dis.close();
                    }
                    if(socket!=null) socket.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }

        }


    }

}
